<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function say() {
            var xhr=new XMLHttpRequest();
            xhr.onreadystatechange=function () {
                if(xhr.readyState==4){
                    if(xhr.status==200){
                        var result=xhr.responseText;
                        msg.innerHTML=result;
                    }else{
                        msg.innerHTML="<font color='red'>需要组件错误</font>";
                    }
                }else{
                    msg.innerHTML="正在校验中...";
                }
            };

            var name=document.getElementById("name").value;
            xhr.open("get","/ajax/servlet/hello?name="+name);
            xhr.send();
        }
    </script>
</head>
<body>
    <a href="javaScript:;" onclick="say()">hello</a><br>
    <input id="name"><br>
    <span id="msg"></span><br>
</body>
</html>